package com.zw.yzk.kabu.data.repository;


import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.AlbumEntity;
import com.zw.yzk.kabu.data.network.service.GetAlbumService;
import com.zw.yzk.kabu.data.network.task.AlbumTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/4.
 */

public class GetAlbumRepository extends CommonRepository {

    @Inject
    public GetAlbumRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        GetAlbumService service = ServiceGenerator.createService(GetAlbumService.class);
        AlbumTask aTask = (AlbumTask) task;
        return service.getAlbum(aTask.id, aTask.lastItemId, aTask.size);
    }

    @Override
    protected Func1<AlbumEntity, Observable> getServerData() {
        return new Func1<AlbumEntity, Observable>() {
            @Override
            public Observable call(AlbumEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
